home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
public
/
Xprof
/
xprof
/
common.h
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
5KB
|
140 lines
/*==================================================================
* File : common.h
* Package: Xprof
*
* Author : Aloke Gupta.
*
* (C) Copyright 1992, Aloke Gupta.
*==================================================================*/
/*
* Declarations shared by the trace analysis routines
*
* Note: The size, in bytes, of each message can be obtained from the
* "request length" parameter in the xscope printout as follows:
* request bytes = (length * 4)
* reply bytes = (length * 4) + 32
* event bytes = 32
* error bytes = 32
*/
#ifndef _COMMON_H_
#define _COMMON_H_
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <values.h>
#include <malloc.h>
#define MAXSTRINGSIZE 16384 /* Conservative large value */
#define MAXBUCKETS_IAT 32 /* Array size for inter-arrival time stats */
extern int MAXBUCKETS_SIZE; /* Array size for size stats */
/* Maximum number of messages of each category */
#define MAXREQUESTS 128
#define MAXREPLIES 41
#define MAXEVENTS 34
#define MAXERRORS 17
/* The following are defined in main.c */
extern long _LINE_NUM;
extern int debuglevel;
extern int verboselevel;
typedef enum {
TRUE = 1, FALSE = 0
} Boolean;
typedef enum { /* mnemonics for FALSE and TRUE */
TERSE = 0, DETAILED = 1
} Detailed;
/* Define macros to extract log2 and antilog of a number. These macros are
* duals of each other. Remember to include math.h
* These functions succesfully handle a zero value, and perform roundoff for
* other cases.
*/
/*
#define mylog2(number) (log2((double) number + 1) + 0.5)
#define myexp2(number) (exp2((double) number) - 1)
*/
#define mylog2(number) ((log((double) number + 1) / log((double) 2.0)) + 0.5)
#define myexp2(number) ((exp((double) number * log((double) 2.0))) - 1)
/*
* GlobalStats contains the totals for client, server, requests, replies, and
* events.
*/
typedef struct {
long current_time; /* The current value of the timestamp in ms */
long last_time; /* The previous value of the timestamp in ms */
/* In the following counts, the following relationships should hold:
* client_bytes = request_bytes
* server_bytes = reply_bytes + event_bytes + error_bytes
*/
unsigned long client_bytes; /* Total number of bytes from client */
unsigned long server_bytes; /* Total number of bytes from server */
/* The following information is redundant since it is maintained in the
* MsgStats structures corresponding to each of the message types. Still
* I maintain it.
*/
unsigned long request_bytes;/* Total number of bytes of request messages */
unsigned long reply_bytes; /* Total number of bytes of reply messages */
unsigned long event_bytes; /* Total number of bytes of event messages */
unsigned long error_bytes; /* Total number of bytes of error messages */
} GlobalStats;
typedef enum { /* Grain sizes for the processed statistics */
GRAIN1 = 1, GRAIN2 = 2, GRAIN4 = 4, GRAIN8 = 8, GRAIN10 = 10,
GRAIN16 = 16, GRAIN32 = 32, GRAIN128 = 128, GRAIN256 = 256, GRAIN512 = 512
} Grain;
#define IAT_GRAIN GRAIN10 /* Interarrival time grain size in ms */
typedef enum { /* Are the buckets linear or log2 ? */
LINEAR, LOG2
} StatsType;
/* The following structure is a generic structure to collect information for
* an arbitrary Xlib message.
* The "iat_distbn", and "size_distbn" arrays are malloced only for the messages
* for which we collect detailed statistics.
*/
typedef struct _MsgStats{
Boolean invoked; /* Has this structure been invoked ?*/
long number; /* Total number of these messages seen */
long total_bytes; /* Total number of bytes seen for this message*/
long last_time; /* What was the time stamp of last message ?*/
Grain size_grain; /* Size grain for this measurement */
Detailed detailed; /* Are we maintaining detailed information ? The
following are updated only if this is TRUE */
long *iat_distbn; /* Interarrival time distribution */
long min_iat, max_iat; /* Range of values of the raw data */
long *size_distbn; /* Size distribution */
long min_size, max_size;
} MsgStats;
typedef enum {
WIN, GFX, TXT
} MsgClass;
/*
* The following structure encapsulates information about a message and the
* action to be taken to process it.
*/
typedef struct _MsgType{
int number; /* Xlib number for this message */
char *name; /* Symbolic name for this message */
MsgClass msgclass; /* Is this a windowing or graphics message ? */
long (*action)(/* FILE *fp, int number, int timestamp */);
/* Action to take to process this message */
Detailed detailed; /* Maintain detailed statistics for this ? */
Grain size_grain; /* Size grain for this measurement ? */
} MsgType;
#endif /* ifndef _COMMON_H_ */